home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / bipl.zip / PROGS.ZIP / FNCTMPL.ICN < prev    next >
Text File  |  1992-09-28  |  2KB  |  67 lines

  1. ############################################################################
  2. #
  3. #    File:     fnctmpl.icn
  4. #
  5. #    Subject:  Program to produce function templates
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     February 27, 1992
  10. #
  11. ###########################################################################
  12. #
  13. #  This program processes the rt.db database for the Icon compiler produced
  14. #  by rtt and produces procedures for each Icon function to be used by
  15. #  iftrace.icn.
  16. #
  17. #  The data base is expected from standard input.
  18. #
  19. ############################################################################
  20.  
  21. procedure main()
  22.    local line, header, proto, rettype, name, varargs
  23.  
  24.    while line := read() do
  25.       line ? {
  26.          if pos(0) then {
  27.             header := read() | stop("eof")
  28.             proto := read() | stop("eof")
  29.             header ? {
  30.                if ="$endsect" then exit()
  31.                tab(upto('{'))
  32.                tab(upto(',') + 1)
  33.                if =("*" | "1+") then rettype := "suspend"
  34.                else rettype := "return"
  35.                }
  36.             proto ? {
  37.                ="\"" | next
  38.                name := tab(bal(' ')) | stop("bad proto")
  39.                name := trim(name,',')
  40.                name ?:= {
  41.                   map(move(1),&lcase,&ucase) || tab(0)
  42.                   }
  43.                name ?:= {
  44.                   if find("...") then {
  45.                      varargs := 1
  46.                      tab(upto('(') + 1) || "x[])"
  47.                      }
  48.                   else {
  49.                      varargs := &null
  50.                      tab(0)
  51.                      }
  52.                   }
  53.                }
  54.             write("procedure ",name)
  55.             if /varargs then write("   ",rettype," ",name)
  56.             else {
  57.                name ?:= {
  58.                   tab(upto('('))
  59.                   }
  60.                write("   ",rettype," ",name," ! x")
  61.                }
  62.             write("end\n")
  63.             }
  64.         else if ="$endsect" then exit()
  65.         }
  66. end
  67.